home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-11-10 | 2.0 KB | 45 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 3558684 7-Nov-89 03:36
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: re DoIt Fail?
-
- It is true that your command will have more memory available to it when DoIt is
- called than when I<YourCommand> is called.
-
- It seem pretty clear what the alternatives are. If you allocate memory in
- I<MyCommand> then you are more likely to run out, but if you do run out, the
- user hasn't lost anything. If you allocate in DoIt, then you have more memory
- available, but if you fail then the user can't undo the previous command.
-
- I think it is better to allocate in I<MyCommand> and not commit the command
- unnecessarily.
-
- Another possibility is to try the allocation in I<MyCommand> and if it fails to
- put up an alert telling the user that memory is low, and that more memory can
- be gained by committingthe last command; should the application proceed?
-
- If the user says NO, then propagate the failure. If the user says YES, then
- record in your command object that the allocation needs to be tried in DoIt.
- Then you can retry it in the DoIt method when more memory should be available.
-
- One enhancement for MacApp would be to keep track of the amount of memory used
- by a command. Then you can test in I<MyCommand> whether committing the last
- command will free enough memory to allow DoIt to succeed.
-
- You might be able to keep track of this number youself, by overriding
- PerformCommand and checking the free memory before and after. (At the start of
- the program the amount of memory tied up in the last command is 0. Checking
- the free memory before and after PerformLast command will tell you the
- difference in memory used by the previous and current command.) This technique
- may not be 100% accurate, because committing a command might not free all the
- space the command allocated; some of that memory might become a permanent part
- of the document.
-
- Larry Rosenstein
-
-